package com.taxi.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.taxi.dto.OrderInfo;
import com.taxi.kafka.KafkaProducer;
import com.taxi.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: aniu
 * @Date: 2023/10/7
 * @ClassName: TestController
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@RestController
public class TestController {

    @Autowired
    private KafkaProducer kafkaProducer;

    @GetMapping("/send-msg")
    public Result Test() throws JsonProcessingException, InterruptedException {
//        for(int i=1;i<=30;i++){
            OrderInfo orderInfo = new OrderInfo();
            orderInfo.setAddress("110000");
            orderInfo.setVehicleNo("京AAAA");
            ObjectMapper objectMapper = new ObjectMapper();
            String msg = objectMapper.writeValueAsString(orderInfo);
            kafkaProducer.sendMessage("travel-topic",msg);
//        }
        return Result.ok();
    }
}
